/*
 * 用户基础类
 * @author: huangzong
 */
import C from '@/common/common.js'

class Factory {
  /*
   * 打开基础设置页面
   */
  async openAddFactory (row) {
    return await C.openBrowserWindow('/addFactory', row, {
      transparent: true,
      frame: false,
      // openDevTools: true,
      width: 390,
      height: 300,
      useSpa: false,
      spaModel: 'shop'
    })
  }

  // 打开分店和总店的厂商列表
  async openFactoryList () {
    return await C.openBrowserWindow('/openFactoryList', {}, {
      transparent: true,
      frame: false,
      // openDevTools: true,
      width: 850,
      height: 800,
      useSpa: false,
      spaModel: 'shop'
    })
  }

  async addFactory (row) {
    if (row.name == '') {
      C.error('请输入厂商名称')
      return false
    }
    return await C.ajax('/shop/factory/addedit', row, 'post')
  }

  async factoryList (filter) {
    return await C.ajax('/shop/factory/factorylist', filter, 'post')
  }

  async changeFactoryStatus (data) {
    return await C.ajax('/shop/factory/unstop', data, 'post')
  }
  // 获取所有的厂商列表
  async getAllFactoryList (filter) {
    return await C.ajax('/shop/factory/getAllFactoryList', filter)
  }
}

export default new Factory()
